package org.datascooter.impl;

import java.util.Arrays;

public class SnipFactory {

	public static Snip copy(Snip data) {
		Snip[] newfetch = null;
		if (data.getFetch() != null && data.getFetch().length > 0) {
			newfetch = new Snip[data.getFetch().length];
			for (int a = 0; a < data.getFetch().length; a++) {
				if (data.getFetch()[a] != null)
					newfetch[a] = copy(data.getFetch()[a]);
			}
		}
		Snip snip = new Snip(data.entity, data.type, data.query, null, data.fields == null ? null : Arrays.copyOf(data.fields, data.fields.length), newfetch, data.parentIndex, data.tranId);
		snip.fromRow = data.fromRow;
		snip.fetchSize = data.fetchSize;
		return snip;
	}


}
